<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>es6-class</title>
</head>
<body>
    <script>
        // function createObj(name){
        //     this.name = name;
        // }
        // createObj.prototype.sayName = function(){
        //     console.log(this.name);
        // }
        // new createObj('zhangsan').sayName(); 

        class CreateObj{
            constructor(name){
                this.name = name;
            }
            sayName(){
                console.log(this.name);
            }
        }
        console.log(new CreateObj('zhangsan'))
    </script>
</body>
</html>